<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    protected $table = 'hawk_role';

    protected $fillable = ['name', 'slug', 'description', 'addTime'];

    const CREATED_AT = 'addTime';
    const UPDATED_AT = null;

    protected $dateFormat = 'U';

    const SLUG_OPERATOR = 'operator';
    const SLUG_WORKSHOP_DIRECTOR = 'workshop_director';
    const PACKAGE_DEPARTMENT_DIRECTOR = 'package_department_director';

    public static function boot()
    {
        parent::boot(); // TODO: Change the autogenerated stub

    }

    public static $defaults = [
        self::SLUG_OPERATOR => [
            'name' => '操作工',
            'permissions' => [

            ],
        ],
        self::SLUG_WORKSHOP_DIRECTOR => [
            'name' => '车间主任',
            'permissions' => [

            ],
        ],
        self::PACKAGE_DEPARTMENT_DIRECTOR => [
            'name' => '包装部主管',
            'permissions' => [

            ],
        ],
    ];

    public function permissions()
    {
        return $this->belongsToMany(Permission::class, 'hawk_role_permission', 'roleId', 'permissionId');
    }

}
